package com.blork.rag;

import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;

public class Network {
	private Context context;
	
	public Network(Context context){
		this.context = context;
	}
	
    public boolean IsDataEnabled(){
    	ConnectivityManager connManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
    	return connManager.getBackgroundDataSetting();
    }
    
    public boolean IsNetworkConnected() {
	  	boolean result = false;
	  	ConnectivityManager connManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
	  	NetworkInfo info = connManager.getActiveNetworkInfo();
	  	if (info == null || !info.isConnected()) {
	  		result = false;
	  	} else {
	  		if (!info.isAvailable()) {
	  			result = false;
	  		} else {
	  			result = true;
	  		}
	  	}
	  	return result;
  	}
}
